from typing import Any, Dict, Optional

from pydantic import BaseModel



class Result(BaseModel):
    code: int
    msg: str
    data: Optional[Any] = None



    @staticmethod
    def success(data: Any = None, msg: str = "成功") -> 'Result':
        return Result(code=200, msg=msg, data=data)

    @staticmethod
    def fail(code: int = 400, msg: str = "失败") -> 'Result':
        return Result(code=code, msg=msg, data=None)
